package com.clsz.controller;


import com.clsz.service.FilmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * 主页
 */
@RestController
@RequestMapping("/index")
public class HomeController {

    @Autowired
    private FilmService filmService;

    /**
     * 首页数据
     *
     * @return
     */
    @GetMapping
    public Object getFirstPageListByTypeId() {
        Map<String, Object> res = new HashMap<>();
        Map<String, Object> data = new HashMap<>();
        res.put("code", "200");
        res.put("message", "ok!!!");
        data.put("currentList", filmService.getListByTypeId(1));
        data.put("currentCount", filmService.getCountByTypeId(1));
        data.put("nextList", filmService.getListByTypeId(2));
        data.put("nextCount", filmService.getCountByTypeId(2));
        data.put("hotList", filmService.getListByTypeId(3));
        data.put("favoriteList", filmService.selectListOrderBy("film_favorite"));
        data.put("praiseList", filmService.selectListOrderBy("film_praise"));
        res.put("data", data);
        return res;
    }

}
